<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<title><fmt:message key="CodeGenerator.title"/> </title>
<menu><fmt:message key="menu.generator.title"/></menu>
<submenu><fmt:message key="menu.generator.title"/></submenu>
<script>
$(".codeGenerator").addClass("active").parent("ul").parent("li").addClass("active open");
$(document).ready(function(){
	checkAllRecord("#checkAll",".checkitems")
})
</script>
<div class="widget-box">
	<div class="widget-header widget-header-blue widget-header-flat">
		<h4 class="widget-title lighter"><fmt:message key="CodeGenerator.title"/></h4>
	</div>
	
	<div class="widget-body">
		<div class="widget-main">
			<div id="fuelux-wizard-container">
				<jsp:include page="generatorStep.jsp"></jsp:include>
				<script>
					$(".step2").addClass("active");
				</script>
				
				<hr />
				
				<div class="step-content pos-rel">
					<div class="step-pane active" data-step="1">
						<h3 class="lighter block green"><fmt:message key="CodeGenerator.selectTable.title"/></h3>
						<fmt:message key="CodeGenerator.tableName.title" var="tableNameTitle"></fmt:message>
						<fmt:message key="CodeGenerator.columnName.title" var="columnNameTitle"></fmt:message>
						<fmt:message key="CodeGenerator.isNullable.title" var="isNullableTitle"></fmt:message>
						<fmt:message key="CodeGenerator.dataType.title" var="dataTypeTitle"></fmt:message>
						<fmt:message key="CodeGenerator.characterMaximumLength.title" var="characterMaximumLengthTitle"></fmt:message>
						<fmt:message key="CodeGenerator.columnType.title" var="columnTypeTitle"></fmt:message>
						
						<form class="form-horizontal" id="confirmColumnForm" method="post" action="${ctx }/codeGenerator">
							<table id="dynamic-table" class="table table-responsive table-striped table-bordered table-hover dataTable">
								<thead>
									<tr>
										<th style="width:1px;"> </th>		
										<th data-name="tableName">${tableNameTitle }</th>
										<th data-name="columnName">${columnNameTitle } </th>
										<th data-name="nullable">${isNullableTitle } </th>
										<th data-name="dataType">${dataTypeTitle } </th>
										<th data-name="characterMaximumLength">${characterMaximumLengthTitle } </th>
										<th data-name="columnType">${columnTypeTitle } </th>
									</tr>
								</thead>
								<tbody>
									<c:forEach items="${columnMap}" var="item" varStatus="status">
										<c:forEach items="${item.value }" var="column" varStatus="columnIndex">
											<tr>
												<td data-label="序号">${status.index + 1}</td>
												<c:if test="${columnIndex.index == 0 }">
													<td data-label="${tableNameTitle }" rowspan="${fn:length(item.value) }"><c:out value='${item.key}'/>&nbsp;</td>
												</c:if>												
												<td data-label="${columnNameTitle }"><c:out value='${column.columnName}'/>&nbsp;</td>
												<td data-label="${isNullableTitle }"><c:out value='${column.nullable}'/>&nbsp;</td>
												<td data-label="${dataTypeTitle }"><c:out value='${column.dataType}'/>&nbsp;</td>
												<td data-label="${characterMaximumLengthTitle }"><c:out value='${column.characterMaximumLength}'/>&nbsp;</td>
												<td data-label="${columnTypeTitle }"><c:out value='${column.columnType}'/>&nbsp;</td>
											  </tr>
										</c:forEach>
										
									</c:forEach>
								</tbody>
							</table>
						</form>
					</div>
				</div>
			</div>
			<hr/>
			<div class="wizard-actions">
				<button class="btn btn-prev">
					<i class="ace-icon fa fa-arrow-left"></i>
					<fmt:message key="navigation.button.prev"/>
				</button>

				<button class="btn btn-success btn-next" data-last="Finish">
					<fmt:message key="navigation.button.next"/>
					<i class="ace-icon fa fa-arrow-right icon-on-right"></i>
				</button>
			</div>
		</div>
	</div>
</div>